<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="200px">
      <el-form-item label="真实姓名">
        {{ name }}
      </el-form-item>
      <el-form-item label="原密码">
        <el-input v-model="form.oldpwd" type="password" placeholder style="width: 500px" class="filter-item" />
      </el-form-item>
      <el-form-item label="新密码">
        <el-input v-model="form.newpwd" type="password" placeholder style="width: 500px" class="filter-item" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submit">修改</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { changePassword } from '@/api/user';
import { mapGetters } from 'vuex';

export default {
  data() {
    return {
      form: {},
    };
  },
  created() {},
  computed: {
    ...mapGetters(['name']),
  },
  methods: {
    async submit() {
      await changePassword({
        form: this.form,
      });
      this.$message({ message: '操作成功！', type: 'success' });

      setTimeout(() => this.$router.go(-1), 500);
    },
  },
};
</script>

<style lang="scss" scoped>
.app-container {
  padding: 40px 5%;

  .line {
    text-align: center;
  }
}
</style>
